package com.todomvc.tests;


import java.util.List;




//import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
//import org.testng.annotations.AfterClass;
//import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.todomvc.fw.NavigationHelper;
import com.todomvc.fw.Todo;
import com.todomvc.fw.TodoHelper;
import com.todomvc.fw.Todos;


public class SelfTests extends TestBase {

	
	private NavigationHelper navMan;
	private TodoHelper todoMan;

	@BeforeClass
	public void getManagers () {
		navMan = manager.getNavigationHelper();
		todoMan = manager.getTodoHelper();
	}
	
	//@AfterClass
	
	@Test
	public void mainPageExists() throws Exception {
		log.info("mainPageExist start");
		//navMan.openMainPage();
		navMan.openAngularPage();

		todoMan.add(new Todo("Say Hello!"));
		todoMan.add(new Todo("Say another hello"));
		todoMan.add(new Todo("Say something"));
		todoMan.add(new Todo("Say goodbye"));
		todoMan.add(new Todo("Say another goodbye"));

		todoMan.toggleFirst();
		todoMan.toggleNth(3);
		todoMan.toggleLast();
			
			//todoMan.clearCompleted();
			
		todoMan.destroyFirst();
		todoMan.destroyNth(3);
		todoMan.destroyLast();
			
		Todos todos = todoMan.getTodos();

		log.info("todos size = " + todos.size());
		log.info("Todos = " + todos);	

		boolean toggleAllCheckboxState = todoMan.getToggleAllCheckboxState();
		log.info("toggleAllCheckboxState = " + toggleAllCheckboxState);

			//List<WebElement> toggleCheckboxList = todoMan.getToggleCheckpointList();

			//log.info("toggleCheckboxList size = " + toggleCheckboxList.size());
			//for (WebElement toggleCheckbox : toggleCheckboxList){
			//	log.info("toggleCheckbox = " + toggleCheckbox.getAttribute("class"));	
			//}

			//List<WebElement> destroyButtonList = todoMan.getDestroyButtonList();

			//log.info("destroyButtonList size = " + destroyButtonList.size());
			//for (WebElement destroyButton : destroyButtonList){
			//	log.info("destroyButton = " + destroyButton.getAttribute("class"));	
			//}

		log.info("todoCount = " + todoMan.getTodoCount());

		log.info("filterState = " + todoMan.getFilterState());

		todoMan.selectFilterActive();
		log.info("Selected Filter 'Active'");

		log.info("filterState = " + todoMan.getFilterState());

		todoMan.selectFilterCompleted();
		log.info("Selected Filter 'Completed'");

		log.info("filterState = " + todoMan.getFilterState());

		todoMan.selectFilterAll();
		log.info("Selected Filter 'All'");

		log.info("filterState = " + todoMan.getFilterState());
			
		log.info("mainPageExist ended");
	}
	
}
